package com.dominator.serviceImpl;

import com.dominFramework.core.typewrap.Dto;
import com.dominator.mybatis.dao.T_entrance_ticketPO;
import com.dominator.repository.DaoEntranceTicket;
import com.dominator.service.ApiEntranceTicketService;
import com.dominator.utils.api.ApiMessage;
import com.dominator.utils.api.ApiMessageUtil;
import com.dominator.utils.api.ApiUtils;
import com.dominator.utils.exception.ApiException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class ApiEntranceTicketServiceImpl implements ApiEntranceTicketService {

    @Autowired
    DaoEntranceTicket daoEntranceTicket;


    @Override
    public ApiMessage createTicket(Dto dto) throws ApiException {
        daoEntranceTicket.addTicket(dto);
        return ApiMessageUtil.success();
    }

    @Override
    public ApiMessage updateTicket(Dto dto) throws ApiException {
        ApiUtils.checkParam(dto, "sn");
        T_entrance_ticketPO po = daoEntranceTicket.selectBySn(dto);
        po.setIs_paid("1");
        daoEntranceTicket.update(po);
        return ApiMessageUtil.success();
    }
}
